home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / smailsrc.zip / PASSWD.ZIP / GETPWNAM.C < prev    next >
Text File  |  1990-04-03  |  523b  |  32 lines

  1. /*
  2.  *      getpwnam.c: Get password file entry by name
  3.  *
  4.  *      Stephen C. Trier
  5.  *      March 26, 1990
  6.  *
  7.  *      This program is in the public domain
  8.  *
  9.  */
  10.  
  11. #include <stdio.h>
  12. #include <string.h>
  13. #include <pwd.h>
  14.  
  15. extern FILE *_pw_file;
  16.  
  17. struct passwd *getpwnam(char *name)
  18. {
  19.     struct passwd *temp;
  20.  
  21.     if (setpwent())
  22.     return NULL;
  23.     while (temp = getpwent())
  24.     if (strcmp(temp->pw_name, name) == 0)  {
  25.         setpwent();
  26.         return temp;
  27.         }
  28.     setpwent();
  29.     return NULL;
  30. }
  31.  
  32.